<?php 
class CommentAction extends ManagerAction{
	function clist(){
		$Comment = M('comment');
		$limit = C('PAGE_COUNT');
		$count = $Comment->count();
		$Page = new Page($count, C('PAGE_COUNT'));
		$limit = "{$Page->firstRow},{$Page->listRows}";
		$field = "comment.*,user.username,activity.name AS activity_name";
		$order = "create_time DESC";
		$join[] = 'LEFT JOIN user ON comment.uid=user.uid';
		$join[] = 'LEFT JOIN activity ON comment.acid=activity.id';
		$list = $Comment->limit($limit)->field($field)->join($join)->order($order)->select();
		$this->assign('page',$Page->show());
		$this->assign('list',$list);
		$this->display();
	}
	function del(){
		$id=$_GET['id'];
		M('comment')->where("id={$id}")->delete();
		$this->success("删除成功！");
	}
	function view(){
		$id=$_GET['id'];
		$Comment = M('comment');
		$comment = $Comment->where("id={$id}")->getField('content');
		echo $comment;
	}
}